package com.icss.th.common;

import com.icss.th.common.config.SystemConfig;
import com.icss.th.question.facade.IOptionFacade;
import com.icss.th.question.facade.IQuestionFacade;
import com.icss.th.question.facade.mongo.OptionFacadeMongo;
import com.icss.th.question.facade.mongo.QuestionFacadeMongo;
import com.icss.th.question.facade.mysql.OptionFacadeMysql;
import com.icss.th.question.facade.mysql.QuestionFacadeMysql;
import com.icss.th.subjects.facade.ISubjectsFacade;
import com.icss.th.subjects.facade.mango.SubjectsFacadeMongo;
import com.icss.th.subjects.facade.mysql.SubjectsFacadeMysql;

public class FacadeFactory 
{	
	public static Object getInstance(Class<?> c)
	{
		Object facade = null;
		
		if (c == IQuestionFacade.class)
		{
			if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MONGODB))
			{
				facade = new QuestionFacadeMongo();
			}
			else if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MYSQL))
			{
				facade = new QuestionFacadeMysql();
			}	
		}
		else if (c == IOptionFacade.class)
		{
			if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MONGODB))
			{
				facade = new OptionFacadeMongo();
			}
			else if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MYSQL))
			{
				facade = new OptionFacadeMysql();
			}
		}
		else if (c == ISubjectsFacade.class)
		{
			if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MONGODB))
			{
				facade = new SubjectsFacadeMongo();
			}
			else if (SystemConfig.DB_TYPE.equals(Constants.DB_TYPE.MYSQL))
			{
				facade = new SubjectsFacadeMysql();
			}
		}
		
		return facade;
	}
}
